package com.eling.elcms.cater.webapp.controller;

import com.eling.elcms.cater.model.DishPrice;
import com.eling.elcms.cater.service.IDishPriceService;
import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
public class DishPriceController extends BaseFormController {

	@Autowired 
	private IDishPriceService dishPriceService;
	
	@RequestMapping("/api/restaurant/dishprice/save")
    @ResponseBody
    public DishPrice save(@ModelAttribute@ModelFilling DishPrice dishPrice) {
		return dishPriceService.save(dishPrice);
    } 
	
	@RequestMapping("/api/restaurant/dishprice/query")
    @ResponseBody
    public List<DishPrice> query(@ModelAttribute DishPrice dishPrice){
		return  dishPriceService.query(dishPrice);
    }
	
	@RequestMapping("/api/restaurant/dishprice/search*")
	@ResponseBody
	public List<DishPrice> sreach(@ModelAttribute SearchCondition sc,@ModelAttribute DishPrice dishPrice) {
		sc.setQueryCondition(dishPrice);
		return dishPriceService.search(sc); 
	}
	
	@RequestMapping("/api/restaurant/dishprice/{pkDishPrice}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkDishPrice) {
		dishPriceService.remove(pkDishPrice);
	    return new Msg("删除成功");
	}
}
